<link
	href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}"
	rel="stylesheet" type="text/css">
<style>
.tree .workUnit a {
	color: #4C9ED9;
}
</style>
<div class="pageContent">
	<div class="treeleft"
		style="width: 280px; float: left; border-right: 1px solid #D8DFE5;">
		<div class="mini-toolbar">
			<input type="text" id="workcenterSearch" /> <a class="buttonActive"
				href="javascript:void(0)" id="searchTree"> <span><@label
					key='search.B'>搜索</@label></span>
			</a>
		</div>
		<div id="menuBar" class="pBar pBarBorder">
			<ul class="toolBar">
				<li><a class="collapse" id="collapsable"
					title='<@label key="collapseAll.D">全部收起</@label>'> <span><@label
							key="collapse.B">收起</@label></span>
				</a></li>
				<li><a class="expand" id="expandable"
					title='<@label key="expandAll.D">全部展开</@label>'> <span><@label
							key="expand.B">展开</@label></span>
				</a></li>
			</ul>
		</div>
		<div id="workcenterTree" layoutH="68">
			<#if workCentersTree??>
			<ul class="tree treeFolder expand"><@macroWorkCenterTree
				children=workCentersTree />
			</ul>
			</#if>
		</div>
		<!-- 递归产生树的宏定义 -->
		<#macro macroWorkCenterTree children> <#if children?? && children?size
		gt 0> <#list children as workCenter>
		<li class='workCenter'
			workcenterCode="${workCenter.workCenterCode!''}"><a
			onclick="$(this).trigger('check');" title="工作中心">${workCenter.workCenterText!''}</a>
			<#if workCenter.childrens?? || workCenter.workUnits?size gt 0>
			<ul>
				<@macroWorkCenterTree children=workCenter.childrens /> <#list
				workCenter.workUnits as workUnit>
				<li class="workUnit" workunitCode="${workUnit.workUnitCode!''}">
					<a onclick="$(this).trigger('check');" title="作业单元">${workUnit.workUnitText!''}</a>
				</li> </#list>
			</ul> </#if></li> </#list> </#if> </#macro>
	</div>
	<div style="margin-left: 281px; margin-top: -1px;" class="pageContent">
		<div id="jGridForMessageConfig" style="float: left; width: 100%;"></div>
	</div>
</div>
<script type="text/javascript">
	(function($) {
		var $page = DWZ.context(), $grid = $('#jGridForMessageConfig', $page), postData = {};
		$grid.jGrid({
			layoutH: 85,
			base: '${rc.getContextPath()}/manage/msgConfig/',
			url: 'getMsgConfigsByCondition',
			autoLoad: false,
			columns: [{
				field: 'id',
				group: 'ids',
				type: 'checkbox',
				width: 22
			}, {
				field: 'strategyText',
				text: '策略描述',
				width: 100,
				defaultOrder: 'asc'
			}, {
				field: 'eventText',
				text: '事件',
				width: 100,
			}, {
				field: 'overtime',
				text: '超时（分钟）',
				width: 100
			}, {
				field: 'receivers',
				text: '收信人',
				width: 100,
				transform: function(data) {
					var userCodes = [];
					for (var index = 0; index < (data || []).length; index++) {
						userCodes.push(data[index].userCode);
					}
					return userCodes.join(', ');
				}
			}, {
				field: 'instantMessageFlag',
				text: '站内信息',
				width: 100,
				transform: function(data) {
					if (data == 0) {
						return '<@label key="no.C">否</@label>';
					} else if (data == 1) {
						return '<@label key="yes.C">是</@label>';
					}
				}
			}, {
				field: 'emailMessageFlag',
				text: '电子邮件',
				width: 100,
				transform: function(data) {
					if (data == 0) {
						return '<@label key="no.C">否</@label>';
					} else if (data == 1) {
						return '<@label key="yes.C">是</@label>';
					}
				}
			}, {
				field: 'lockFlag',
				text: '启用',
				width: 100,
				transform: function(data) {
					if (data == 1) {
						return '<@label key="no.C">否</@label>';
					} else if (data == 0) {
						return '<@label key="yes.C">是</@label>';
					}
				}
			}],
			getQueryData: function() {
				return postData;
			},
			gridbars: [{
				icon: 'add',
				text: '<@label key="add.B"></@label>',
				title: '新增消息配置',
				target: 'dialog',
				href: 'addMsgConfig',
				data: {
					navTabId: "${navTabId!''}"
				},
				mask: true,
				width: 640,
				height: 480
			}, {
				icon: 'edit',
				text: '<@label key="edit.B"></@label>',
				title: '编辑消息配置',
				target: 'dialog',
				href: 'modifyMsgConfig',
				data: {
					navTabId: "${navTabId!''}",
					workcenterCode: '{workcenterCode}',
					workunitCode: '{workunitCode}',
					id: '{id}'
				},
				mask: true,
				width: 640,
				height: 480
			}, {
				icon: 'icon',
				text: '<@label key="view.B"></@label>',
				title: '消息配置详情',
				target: 'dialog',
				href: 'viewMsgConfig',
				data: {
					navTabId: "${navTabId!''}",
					workcenterCode: '{workcenterCode}',
					workunitCode: '{workunitCode}',
					id: '{id}'
				},
				mask: true,
				width: 640,
				height: 480
			}, {
				icon: 'add',
				text: '<@label key="copy.B"></@label>',
				title: '复制消息配置',
				target: 'dialog',
				href: 'copyMsgConfig',
				data: {
					navTabId: "${navTabId!''}",
					workcenterCode: '{workcenterCode}',
					workunitCode: '{workunitCode}',
					id: '{id}'
				},
				mask: true,
				width: 640,
				height: 480
			}, {
				icon: 'delete',
				text: '<@label key="delete.B">删除</@label>',
				title: "确认要删除选择的消息配置吗？",
				target: 'selectedTodo',
				href: 'deleteMsgConfig',
				data: {
					ids: '{ids}',
					navTabId: '${navTabId!""}'
				}
			}]
		});

		$("#searchTree", $page).baseTreeSearch({
			inputTextId: "#workcenterSearch",
			alertMsg: "<@label key='Tree_search_Input.D'>输入名称进行查询</@label>", //提示内容，要考虑国际化，传自后台
			$p: $page
		});

		$("#collapsable", $page)._treeCollapsable({
			$p: $page
		})

		$("#expandable", $page)._treeExpandable({
			$p: $page
		});

		$('#workcenterTree .tree', $page).on('check', '.workCenter, .workUnit', function(event) {
			var $this = $(this);
			postData = {};
			if ($this.is('.workCenter')) {
				postData.workcenterCode = $(this).attr('workcenterCode');
			} else if ($this.is('.workUnit')) {
				postData.workunitCode = $(this).attr('workunitCode');
			}
			$grid.jGrid('loadData');
			return false;
		});

		$(function() {
			$('#workcenterTree .tree a:first', $page).click();
		});

	})(jQuery);
</script>